<script lang="ts" setup>
	import { ref, reactive,getCurrentInstance} from "vue";
	import { onLoad, onReachBottom } from '@dcloudio/uni-app';
	import workerCard from "@/components/worker-card/worker-card.vue"
	const { proxy } = getCurrentInstance()
	const searchList = () => {
		state.pageNo = 1;
		state.total = 0
		state.list = []
		getList()
	}
	let state = reactive({
		total: 0,
		pageNo: 1,
		pageSize: 10,
		list:[],
		name: '',
	})
	onLoad((options)=>{
		state.name = options.value
		getList()
	})
	onReachBottom(() => {
		if (state.total > state.list.length) {
			state.pageNo++
			getList()
		}
	})
	
	
	const getList = () => {
		let params = {
			pageNo: state.pageNo,
			pageSize: state.pageSize,

			positionName: state.name
	
		}
		proxy.$req('GET', proxy.$api.meiyeRecruitHunterInfo3List, params).then((res) => {
			console.log(res);
			if (res.code === 200) {
				state.total = res.result.total
				state.list = state.list.concat(res.result.records)
				// state.list = res.result.records
			}
		})
	}
</script>
<template>
	<view class="navbar">
		<u-navbar :placeholder="true" leftText="" title="" auto-back>
			<template #center>
				<view style="width: 70%;">
					<u-search placeholder="搜索" v-model="state.name" :showAction="false"
						@search="searchList"></u-search>
				</view>
			</template>
			<template #right >
				<text @click="searchList">搜索</text>
				
			</template>
		</u-navbar>
	</view>
	<view class="jobCardBox">
		<worker-card :list="state.list" @toCall="toCall"></worker-card>
	</view>
</template>
<style lang="scss" scoped>
	page {
		background: #f6f6f6;
		height: 100%;
	}
	.navbar {
		width: 100%;
		height: 100rpx;
	}

	.jobCardBox {
		overflow-y: auto;
	}
</style>